<%-- 
    Document   : ExamenMain
    Created on : 10/10/2011, 03:48:44 PM
    Author     : Alumnos
--%>


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.sql.*" %>
<!DOCTYPE html>

<%
    Connection conn = null;
    try {
        String sc = "jdbc:mysql://localhost:3306/upeu?user=root&password=";
        Class.forName("com.mysql.jdbc.Driver");
        conn = DriverManager.getConnection(sc);
        System.out.println("Conectado");%>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>EXAMEN CRUD</title>
    </head>
    <body>
        <form action="ExamenSave.jsp">
            <table>
                <tr>
                    <th>Datos del Alumno</th>
                </tr>

                <tr>
                    <td>Name</td>
                    <td><input type="text" name="nombre" id="nombre"/></td>      
                </tr>

                <tr>
                    <td>Photo</td>
                    <td><input type="text" name="photo" id="photo"/></td>                
                </tr>

                <tr>
                    <td>Email</td>
                    <td><input type="text" name="email" id="email"/></td>                
                </tr>
               
                <tr>
                    <td>Cellular</td>
                    <td><input type="text" name="celular" id="celular"/></td>                
                </tr>
                  <tr>
                    <td>Login</td>
                    <td><input type="text" name="login" id="login"/></td>                
                </tr>
                <tr>
                    <td>Password</td>
                    <td><input type="password" name="Password" id="password"/></td>                
                </tr>
                 <tr>
                    <td>Privilege</td>
                    <td><input type="text" name="Privilege" id="Privilege"/></td>                
                </tr>
                
                 <tr>
                    <td>ActiveAccount</td>
                    <td><input type="text" name="ActiveAccount" id="ActiveAccount"/></td>                
                </tr>
                <tr>
                    <td>ForcePasswordChange</td>
                    <td><input type="text" name="ForcePasswordChange " id="ForcePasswordChange "/></td>                
                </tr>
                 <tr>
                    <td>DateCreate</td>
                    <td><input type="text" name="DateCreate " id="DateCreate "/></td>                
                </tr>
                
                <tr>
                <input type="submit" value="Guardar"/>
                </tr>
            </table>
        </form>
      

        <table>

            <tr>
                <th>TABLA DE DATOS</th> 
            </tr>
            <tr>
                <th width="120">USERID</th>
                <th width="120">Nombre</th>
                <th width="120">Photo</th>
                <th width="120">Email</th>
                <th width="120">Cellular</th>
                <th width="120">Login</th>
                <th width="120">Password</th>
                <th width="120">Privilege</th>
                <th width="120">ActiveAccount</th>
                <th width="120">ForcePasswordChange</th>
                <th width="120">DateCreate</th>
                <th colspan="2">Opciones</th>
            </tr>


                 
            <%  int x = 1;
                String qry = "select * from user";
                PreparedStatement ps = conn.prepareStatement(qry);
                ResultSet rs = ps.executeQuery();
       while (rs.next()) {%>         
            <tr>
                <th><%= x++%></th>
                <th><%= rs.getString("nombre")%></th>
                <th><%= rs.getString("photo")%></th>
                <th><%= rs.getString("celular")%></th>
                <th><%= rs.getString("login")%></th>
                <th><%= rs.getString("password")%></th>
                <th><%= rs.getString("privilege")%></th>
                <th><%= rs.getString("activeaccount")%></th>
                <th><%= rs.getString("forcepasswordchange")%></th>
                <th><%= rs.getString("datecreate")%></th>
                
                
                <th><a  href=remove.jsp?userid=<%= rs.getString("userid")%>>Eliminar</a></th>
                <th><a  href=update.jsp?userid=<%= rs.getString("userid")%>>Modificar</a> </th>
            </tr>          



            <%
                    }} catch (Exception e) {
                    out.print("Error: " + e.getMessage());
                }
            %>
        </table> 
    </body>
</html>
